#include "Background.h"
#include <fstream>
#include <iostream>
#include "../Games/MyGame.h"

Background::Background(int maxFrequency, std::string name) :
		GameEntity(maxFrequency, name)
{
	_directionState = NONE;
}

Background::~Background()
{
}

void Background::draw()
{	
		//GameEngine::Instance()->getRenderer()->drawModel("airplane",0,150,-100,90);
	GameEngine::Instance()->getRenderer()->drawPieceQuad("background.raw\0", 1,1,1, this->getPosition(),this->getOrientation(), 128);
}

void Background::actualUpdate(int timePassed)
{
	POINT3D newPosition = {getPosition().x, getPosition().y, getPosition().z};

	switch(_directionState) {
	case LEFT: 
		newPosition.x--;
		break;
	case RIGHT: 
		newPosition.x++;
		break;
	case UP: 
		newPosition.y++;
		break;
	case DOWN: 
		newPosition.y--;
		break;
	}
	setPosition(newPosition);
	_directionState = NONE;
}
void Background::onMouseScrolled(int xcoord, int ycoord, int distance){
}

void Background::reset(){}

void Background::onKeyPressed(int key){
	switch(key)
	{		
		case 'a':case 'A':	_directionState = LEFT;
					break;
		case 'd':case 'D':	_directionState = RIGHT;
					break;
		case 'w':case 'W':	_directionState = UP;
					break;
		case 's':case 'S':	_directionState = DOWN;
					break;
	}
}			//If a key is pressed, this function is called
void Background::onKeyReleased(int){}		//If a key is released, this function is called

void Background::onMouseMoved(int, int){}			//If a mouseIsMoved, this function is called
void Background::onMouseClicked(int, int){}			//If a mouseIsClicked, this function is called

int Background::getType() {
	return GameEntity::Background;
}